<?php
/**
 * [WeEngine System] Copyright (c) 2013 WE7.CC
 * $sn$
 */
define('IN_IA', true);
define('IA_ROOT', dirname(dirname(__FILE__)));

require IA_ROOT.'/framework/class/loader.class.php';

load()->func('global');
load()->model('user');
load()->classs('cache');

define('TIMESTAMP', time());
define('CLIENT_IP', getip());

define('DEBUG', CLIENT_IP == '127.0.0.1');
if (DEBUG) {
	ini_set('display_errors', '1');
	error_reporting(E_ALL ^ E_NOTICE);
} else {
	error_reporting(0);
}

$_W = $_GPC = array();

$_W['isajax'] = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
$_W['ispost'] = $_SERVER['REQUEST_METHOD'] == 'POST';

$_GET = istripslashes($_GET);
$_POST = istripslashes($_POST);

if (empty($_GET['dataType'])) {
	$_W['dataType'] = 'json';
} else {
	$_W['dataType'] = $_GET['dataType'];
}

if (isset($_GET['api_qs'])) {
	$qs = json_decode(base64_decode($_GET['api_qs']), true);
	if (is_array($qs)) {
		$_GET = array_merge($_GET, $qs);
	}
	unset($qs);
}

$_GPC = array_merge($_GET, $_POST);
$_GPC = ihtmlspecialchars($_GPC);

$class = $_GPC['c'];
$method = $_GPC['a'];

current_developer(['uid' => $_GPC['__api_uid']]);

unset($_GPC['__api_uid'], $_GET['__api_uid']);

header('Content-Type: text/html; charset=utf-8');
